package cn.yql8.service.impl;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;

import cn.yql8.bean.Group;
import cn.yql8.bean.User;
import cn.yql8.dao.base.UserDao;
import cn.yql8.dao.other.GroupDao;
import cn.yql8.exception.BaseException;
import cn.yql8.service.UserService;
@Service("userService")
public class UserServiceImpl implements UserService{
	private Log logger = LogFactory.getLog(UserServiceImpl.class);
	
	@Resource(name="groupDao")
	private GroupDao groupDao;
	
	@Resource(name="userDao")
	private UserDao userDao;
	public User getById(int id) throws Exception{
		
		User user = this.userDao.getById(id);
		if(0 == 0){
			throw new BaseException("错误了哦");
		}
		return user;
	
	}
	public void add(User user) {
		this.userDao.add(user);
	}
	public void addGroupAndUser(Group group, User user) {
		this.groupDao.add(group);
		this.userDao.add(user);
	}

}
